<?php
/**
 * Created by PhpStorm.
 * User: mars
 * Date: 2018/8/28
 * Time: 下午9:38
 */

namespace api\controllers;


use api\models\Fans;
use api\models\User;
use yii\helpers\ArrayHelper;
use yii\rest\ActiveController;
use yii\web\Response;

class FansController extends ARBaseController {

	public $modelClass= 'api\models\Fans';

//	public function behaviors()
//	{
//		$behaviors = parent::behaviors();
//		$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;//默认浏览器打开返回json
//		return $behaviors;
//	}

	public function actions() {
		$actions =  parent::actions(); // TODO: Change the autogenerated stub
		unset($actions['delete']);
		return ArrayHelper::merge($actions,[
			'delete'
		]);
	}

	public function actionDelete($id){
		$uid = User::findIdentityByAccessToken(\Yii::$app->request->getHeaders()->get('access-token'))->id;
		$model = Fans::findOne(['cid'=>$uid,'ccid'=>$id]);
		return $model->delete();
	}

}